package com.btpj.jetpack.entity

import com.btpj.jetpack.http.exception.ResultException

/**
 * 请求返回结果密封类
 *
 * @author LTP 2020/7/8
 */
sealed class ApiResult<out T : Any> {

    data class Success<out T : Any>(val data: T) : ApiResult<T>()

    data class Error(val exception: ResultException) : ApiResult<Nothing>()

    override fun toString(): String {
        return when (this) {
            is Success -> "请求成功：$data"
            is Error -> "请求错误：$exception"
        }
    }
}